﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;

namespace YasharEl.Infrastructure.TaskEngine.DomainModel
{
    [ContractClass(typeof(TaskConsultingManagerContract))]
    public interface ITaskConsultingManager
    {
        #region Consult Methods

        void Consult(long applicationId, long userId, long taskInstanceId, long fromUserId, long consultWith, string comment);

        void ConsultAnswer(long applicationId, long userId, long taskInstanceId, long fromUserId, string comment);

        void CancelConsult(long applicationId, long userId, long taskInstanceId, string comment);

        #endregion
    }

    [ContractClassFor(typeof(ITaskConsultingManager))]
    internal abstract class TaskConsultingManagerContract : ITaskConsultingManager
    {
        public void Consult(long applicationId, long userId, long taskInstanceId, long fromUserId, long consultWith, string comment)
        {
            Contract.Requires<ArgumentNullException>(applicationId > 0, "applicationId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(userId > 0, "userId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(taskInstanceId > 0, "taskInstanceId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(fromUserId > 0, "fromUserId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(consultWith > 0, "consultWith must be valid positive numeric value.");
        }


        public void CancelConsult(long applicationId, long userId, long taskInstanceId, string comment)
        {
            Contract.Requires<ArgumentNullException>(applicationId > 0, "applicationId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(userId > 0, "userId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(taskInstanceId > 0, "taskInstanceId must be valid positive numeric value.");
        }

        public void ConsultAnswer(long applicationId, long userId, long taskInstanceId, long fromUserId, string comment)
        {
            Contract.Requires<ArgumentNullException>(applicationId > 0, "applicationId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(userId > 0, "userId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(taskInstanceId > 0, "taskInstanceId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(fromUserId > 0, "fromUserId must be valid positive numeric value.");
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(comment), "comment could not be null or empty.");
        }
    }
}
